<template>
  <div class="page-out">
    <counter-result-intro
      :storeName="model.storeName"
      :address="model.address"
      :chanel="model.channel"
      :type="model.type"
      v-if="model.address"
    ></counter-result-intro>
  </div>
</template>

<script>
import CounterResultIntro from "@/components/CounterResultIntro";
import * as Api from "@/service";
import utils from "@/utils";
import FastClick from "fastclick";
export default {
  data() {
    return {
      model: {}
    };
  },
  created() {
    document.body.style.minHeight = "598px";
    document.documentElement.style.minHeight = "598px";
    this.over();
    this.getInfo();
  },
  mounted() {
    console.log(this.$children);
    FastClick.attach(document.querySelector(".page-out"));
  },
  beforeDestroy() {
    document.body.style.minHeight = 0;
    document.documentElement.style.minHeight = 0;
  },
  components: {
    CounterResultIntro
  },
  methods: {
    over() {
      // let discern =
      //   localStorage.getItem("camellia-sample-discern") ||
      //   this.$route.query.discern;
      // utils.isOver(discern).then(res => {
      //   if (res) {
      //     this.$router.push("/over");
      //   }
      // });
    },
    async getInfo() {
      let channel = utils.getChannelInfo().channel;
      try {
        const discern =
          this.$route.query.discern ||
          localStorage.getItem("camellia-sample-discern");
        if (!discern) return this.$router.replace("/");
        const { data } = await Api.getCheckInfo({
          discern
        });
        console.log(data);
        this.model = data;
        // channel = this.model.channel;
      } catch (error) {
        console.log(error);
        if (error.code === "10004") {
          error.message = "无用户信息";
          alert(error.message);
        }
        console.log("result");
        this.$router.replace("/");

        localStorage.removeItem("camellia-sample-discern");
      }
    }
  }
};
</script>

<style lang="less" scoped>
.page-out {
  min-height: 100%;
  height: 100%;
}
</style>
